package com.lagou.demo03.dao;

import com.lagou.demo03.model.Student;
import com.lagou.demo03.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class StudentDelDaoImp implements StudentDelDao {
    @Override
    public String studentDel(String delId){
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {

            //获取数据库连接
            connection = DbUtil.getConnection();
            //从数据库中获取数据
            String sql2 = "DELETE FROM t_student WHERE id = ?";
            //执行sql，并获取结果返回
            preparedStatement = connection.prepareStatement(sql2);
            preparedStatement.setString(1,delId);
            preparedStatement.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                DbUtil.closeResource(connection,preparedStatement);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}
